/**
 * \file CPrintPreviewFrm.h
 * \author Corentin Le Bail
 * \date 2009-2013
 * \brief Fichier de déclaration de la class CPrintPreviewFrm
 */
//------------------------------------------------------------------------------
#ifndef __CPRINTPREVIEWFRM_H__
#define __CPRINTPREVIEWFRM_H__
//------------------------------------------------------------------------------
#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <poppler-qt4.h>
#include "ui_CPrintPreviewFrm.h" 
#include "CRequest.h"
//------------------------------------------------------------------------------
/**
 * \class CPrintPreviewFrm CPrintPreviewFrm.h "CPrintPreviewFrm.h"
 * \brief Classe de la fenêtre d'aperçu avant impression.
 */
class CPrintPreviewFrm : public QDialog, private Ui::PrintPreviewFrm {
	Q_OBJECT
	public:
		/**
		 * \enum EPrintType
		 * \brief Destination de l'impression.
		 */
		typedef enum {eptScreen, eptPrinter, eptFile} EPrintType;
		
		/**
		 * \fn static CPrintPreviewFrm *getInstance(void)
		 * \return L'instance de l'objet
		 */
		static CPrintPreviewFrm *getInstance(void);
		/**
		 * \fn void print(CRequest *request, EPrintType printType, QWidget *parent)
		 * \brief Imprime le document docName provenant de l'url url vers printType \ref CPrintPreviewFrm::EPrintType
		 * \param[in] request Référence vers un objet request
		 * \param[in] printType Destination de l'impression
		 * \param[in] parent Référence vers un objet parent
		 */
		void print(CRequest *request, EPrintType printType, QWidget *parent);
	private:
		Poppler::Document *doc;
		QWidget *_parent;
		EPrintType _printType;
		static CPrintPreviewFrm * instance;
		int nbPage;
		int currentPage;
		QLabel *pdfRender;
		QByteArray datas;
		QString contentType;
		
		CPrintPreviewFrm(void);
		void toScreen(void);
		void toPrinter(void);
		void toFile(void);
		void renderPage(int pageNum);
	private slots:
		void on_premierePage_clicked(void);
		void on_pagePrecedente_clicked(void);
		void on_pageSuivante_clicked(void);
		void on_dernierePage_clicked(void);
		void on_cbZoom_currentIndexChanged(int index);
		void on_printDocument_clicked(void);
		void on_leFrom_textEdited(const QString &text);
		void on_printToFile_clicked(void);
};
//------------------------------------------------------------------------------
#endif //__CPRINTPREVIEWFRM_H__
//------------------------------------------------------------------------------

